#pragma once
#include "soapStub.h"
#include "IOnvifToolClass.h"
#include <vector>
#include <optional>
using std::optional;
using std::string;
using std::vector;
namespace onvif_tool_json_operation
{

    class jsonOperation
    {
    public:
        static optional<string> parseConfig(string &jsonStr, tt__Config *config);
        static optional<string> parse1DSpace(string &jsonStr, tt__Space1DDescription *space);
        static optional<string> parse2DSpace(string &jsonStr, tt__Space2DDescription *space);
        static optional<string> parsePTZSpace(string &jsonStr, tt__PTZSpaces *space);
        static optional<string> parsePTZVector(string &jsonStr, tt__PTZVector *PTZVector);
        static optional<string> parseGeoLocation(string &jsonStr, tt__GeoLocation *location);
        static optional<string> parseGeoOrientation(string &jsonStr, tt__GeoOrientation *orientation);
        static optional<string> parseLocalLocation(string &jsonStr, tt__LocalLocation *location);
        static optional<string> parseLocalOrientation(string &jsonStr, tt__LocalOrientation *orientation);
        static optional<string> parseLocationEntity(string &jsonStr, tt__LocationEntity *entity);
        static optional<string> parseNetworkInterface(string &jsonStr, tt__NetworkInterface *interface_);
        static optional<string> parseVideoSource(string &jsonStr, tt__VideoSource *videoSource);
        static optional<string> parseVideoSourceConfiguration(string &jsonStr, tt__VideoSourceConfiguration *config);
        static optional<string> parseVideoOutputConfiguration(string &jsonStr, tt__VideoOutputConfiguration *config);
        static optional<string> parseVideoSourceConfigurationOptions(string &jsonStr, tt__VideoSourceConfigurationOptions *option);
        static optional<string> parseVideoSourceMode_V1(string &jsonStr, trt__VideoSourceMode *mode);
        static optional<string> parseVideoSourceMode_V2(string &jsonStr, ns1__VideoSourceMode *mode);
        static optional<string> parseVideoEncoderConfiguration_V1(string &jsonStr, tt__VideoEncoderConfiguration *config);
        static optional<string> parseVideoEncoderConfiguration_V2(string &jsonStr, tt__VideoEncoder2Configuration *config);
        static optional<string> parseVideoEncoderConfigurationOptions_V1(string &jsonStr, tt__VideoEncoderConfigurationOptions *option);
        static optional<string> parseVideoEncoderConfigurationOptions_V2(string &jsonStr, tt__VideoEncoder2ConfigurationOptions *option);
        static optional<string> parseAudioSourceConfiguration(string &jsonStr, tt__AudioSourceConfiguration *config);
        static optional<string> parseAudioOutputConfiguration(string &jsonStr, tt__AudioOutputConfiguration *config);
        static optional<string> parseAudioOutputConfigurationOptions(string &jsonStr, tt__AudioOutputConfigurationOptions *option);
        static optional<string> parseAudioEncoderConfiguration_V1(string &jsonStr, tt__AudioEncoderConfiguration *config);
        static optional<string> parseAudioEncoderConfiguration_V2(string &jsonStr, tt__AudioEncoder2Configuration *config);
        static optional<string> parseAudioEncoderConfigurationOptions(string &jsonStr, tt__AudioEncoderConfigurationOptions *option);
        static optional<string> parseAudioDecoderConfiguration(string &jsonStr, tt__AudioDecoderConfiguration *config);
        static optional<string> parseAudioDecoderConfigurationOptions_V1(string &jsonStr, tt__AudioDecoderConfigurationOptions *option);
        static optional<string> parseAudioEncoderDecoderConfigurationOptions_V2(string &jsonStr, tt__AudioEncoder2ConfigurationOptions *option);
        static optional<string> parseMetadataConfiguration(string &jsonStr, tt__MetadataConfiguration *config);
        static optional<string> parseMetadataConfigurationOptions(string &jsonStr, tt__MetadataConfigurationOptions *option);
        static optional<string> parseVideoAnalyticsConfiguration(string &jsonStr, tt__VideoAnalyticsConfiguration *config);
        static optional<string> parsePTZConfiguration(string &jsonStr, tt__PTZConfiguration *config);
        static optional<string> parsePTZConfigurationOptions(string &jsonStr, tt__PTZConfigurationOptions *option);
        static optional<string> parseProfiles_V1(string &jsonStr, tt__Profile *profile);
        static optional<string> parseProfiles_V2(string &jsonStr, ns1__MediaProfile *profile);
        static optional<string> parseOSD(string &jsonStr, tt__OSDConfiguration *config);
        static optional<string> parseOSDOptions(string &jsonStr, tt__OSDConfigurationOptions *option);
        static optional<string> parseRecordingInformation(string &jsonStr, tt__RecordingInformation *info);

        static optional<string> buildNetworkInterfaceSetConfiguration(tt__NetworkInterfaceSetConfiguration &networkInterface,
                                                                      ONVIF_SET_NETWORK_INTERFACE_PARAM *param);
        // 该delete方法仅用于delete掉 buildNetworkInterfaceSetConfiguration 方法申请的空间
        static void deleteNetworkInterfaceSetConfiguration(tt__NetworkInterfaceSetConfiguration *networkInterface);

        static optional<string> buildOSDConfiguration(tt__OSDConfiguration &OSD, ONVIF_SET_OSD_PARAM *param);
        // 该delete方法仅用于delete掉 buildOSDConfiguration 方法申请的空间
        static void deleteOSDConfiguration(tt__OSDConfiguration *OSD);

    private:
        static string makeErrorStr(string errPrefix, string err);
    };

}